#!/usr/bin/python
#-*- coding:utf-8 -*-
import re

# 提取logger4j日志文件

r1=re.compile(r'at org.')
r2=re.compile(r'WARN')
r3=re.compile(r'ERROR')
r4=re.compile(r'Can not initialize counter due to context is not a')
r5=re.compile(r'(unknown error)')
r6=re.compile(r'error')
f0=file('nohup_main_new.log','r')
dat0=f0.readlines()
f0.close()
f1=file('result.txt','w')
j=0
for i in dat0:
    if (r1.search(i) or r2.search(i) or r3.search(i) or r6.search(i)) and not r4.search(i) and not r5.search(i):
        f1.write(i)
        j=j+1
print('total lines: ',j)
f1.close()

